package com.fallsvc.order.service;

import com.fallsvc.api.ProductApi;
import com.fallsvc.model.ProductInfo;
import com.fallsvc.order.mapper.OrderMapper;
import com.fallsvc.order.model.OrderInfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @auther falls_vc
 * description:
 * @date 2025/5/25  11:03
 */
@Service
public class OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private ProductApi productApi;
    public OrderInfo selectOrderById(Integer id) {
        OrderInfo orderInfo = orderMapper.selectOrderById(id);
//        String url="http://product-service/product/"+orderInfo.getProductId();
//        ProductInfo productInfo = restTemplate.getForObject(url, ProductInfo.class);
       ProductInfo productInfo = productApi.getProductInfo(orderInfo.getProductId()) ;
       orderInfo.setProductInfo(productInfo);
        return orderInfo;
    }
}
